package trunk;

public class Cell implements Saveable<Cell> {
	// tile type constants
	// if Normal character can stand on this tile then constant%2 = standable
	public static final int STANDABLE_TILE = 0;
	public static final int NORMAL_TILE = 0;
	public static final int OPEN_DOOR_TILE = 2;

	// else tile_constant%2 = obstruction
	public static final int OBSTRUCTION_TILE = 1;
	public static final int STONE_TILE = 1;
	public static final int CLOSED_DOOR_TILE = 3;

	private int tileType;
	private LivingThing livingThing;

	public Cell(int type) {
		tileType = type;
		livingThing = null;
	}

	public void setLivingThing(LivingThing c) {
		livingThing = c;
	}

	public LivingThing getLivingThing() {
		return livingThing;
	}

	public int getType() {
		return tileType;
	}

	public void setType(int newType) {
		tileType = newType;
	}

	public boolean isStandable() {
		if (tileType % 2 == STANDABLE_TILE && livingThing == null)
			return true;
		else
			return false;
	}

	@Override
	public Cell load(String str) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String save() {
		String save = "{";
		save += tileType;
		save += ";";
		if (livingThing != null)
			save += livingThing.save();
		save += "}";
		return save;
	}
}
